import datetime
import backtrader as bt
import matplotlib.pyplot as plt
plt.rcParams["figure.dpi"] = 200
from screener1 import Screener_Bottom

#Instantiate Cerebro engine
#Add data to Cerebro
# instruments = ['TSLA', 'AAPL', 'GE', 'GRPN']

#Add analyzer for screener


if __name__ == '__main__':
    # OCEA PHUN SATL COCH LVTX APM MEDS
    instruments = ['OCEA']
    for ticker in instruments:
        data = bt.feeds.YahooFinanceCSVData(
            dataname='../csv/{}.csv'.format(ticker),
            fromdate=datetime.datetime(2023, 1, 1),
            # todate=datetime.datetime(2024, 2, 29),
            todate=datetime.datetime.now(),
        )
        
        cerebro = bt.Cerebro()
        cerebro.addanalyzer(Screener_Bottom)
        # cerebro.addstrategy(Screener_Bottom)
        
        cerebro.adddata(data)
        
        cerebro.run(runonce=False, stdstats=False, writer=True)
        cerebro.plot(style='candle')
